/**
 * FileName: MyBatisUtils
 * Author: TangZaoBang
 * Date: 2023/05/09 10:18
 * Description:
 * <p>
 * History:
 * <author> TangZaoBang
 * <time> 2023/05/09 10:18
 * <version> 1.0.0
 * <desc> 版本描述
 */

package com.bosssoft.hr.train.j2se.mybatis.utils;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.Reader;

/**
 * @Class MyBatisUtils
 * @Description  MyBatisUtils
 * @Author TangZaoBang
 * @Date 2023/05/09 10:18
 * @Version
 */
@Slf4j
public class MyBatisUtils {
    private static final SqlSessionFactory sqlSessionFactory;

    private MyBatisUtils(){}

    static {
        String resource = "mybatis-config.xml";
        Reader reader = null;
        try {
            reader = Resources.getResourceAsReader(resource);
        } catch (IOException e) {
            log.info(e.getMessage());

        }
        sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
    }

    public static SqlSessionFactory getSqlSessionFactory() {
        return sqlSessionFactory;
    }

}